import librosa
import soundfile


def main():
	filename = "../resources/yqx.wav"
	# 如果 sr 缺省，librosa.load()会默认以22050的采样率读取音频文件，
	# 高于该采样率的音频文件会被下采样，低于该采样率的文件会被上采样。
	# librosa.load()只能读取单通道音频
	y, sample_rate = librosa.load(filename, sr=48000)
	data, sr = soundfile.read(filename)
	print(type(y))
	print(type(data))
	print(sample_rate)
	print(sr)

	print(y.shape)
	print(data.shape)

	#if(data[:,0] == data[:,1]):
	#	print("same")

	print((data[:,0] == data[:,1]).any())

	print(data[10000:10050,0])
	print(data[10000:10050,1])

	soundfile.write("../resources/yqx_l.wav", data, sr)

	

if __name__ == '__main__':
	main()